
from ggrc.converters import errors
from integration.ggrc import TestCase


class TestBasicCsvImport(TestCase):

  def setUp(self):
    TestCase.setUp(self)
    self.client.get("/login")

  def test_policy_basic_import(self):
    filename = "ca_setup_for_deletion.csv"
    self.import_file(filename)

    filename = "ca_deletion.csv"
    response_data_dry = self.import_file(filename, dry_run=True)
    response_data = self.import_file(filename)
    self.assertEqual(response_data_dry, response_data)

    self.assertEqual(response_data[0]["deleted"], 2)
    self.assertEqual(response_data[0]["ignored"], 0)


from integration.ggrc import TestCase


class TestBasicCsvImport(TestCase):

  def setUp(self):
    TestCase.setUp(self)
    self.client.get("/login")

  def test_policy_basic_import(self):
    filename = "ca_setup_for_deletion.csv"
    self.import_file(filename)

    filename = "ca_deletion.csv"
    response_data = self.import_file(filename)

    self.assertEqual(response_data[0]["deleted"], 2)
    self.assertEqual(response_data[0]["ignored"], 0)

Optimize basic delete import tests
Optimize basic delete import tests

The dry-run check is now automatically performed on each import and we
do not need to duplicate the work in the delete test.

  
- from ggrc.converters import errors
  from integration.ggrc import TestCase
  
  
  class TestBasicCsvImport(TestCase):
  
    def setUp(self):
      TestCase.setUp(self)
      self.client.get("/login")
  
    def test_policy_basic_import(self):
      filename = "ca_setup_for_deletion.csv"
      self.import_file(filename)
  
      filename = "ca_deletion.csv"
-     response_data_dry = self.import_file(filename, dry_run=True)
      response_data = self.import_file(filename)
-     self.assertEqual(response_data_dry, response_data)
  
      self.assertEqual(response_data[0]["deleted"], 2)
      self.assertEqual(response_data[0]["ignored"], 0)
  
Optimize basic delete import tests
## Code Before:

from ggrc.converters import errors
from integration.ggrc import TestCase


class TestBasicCsvImport(TestCase):

  def setUp(self):
    TestCase.setUp(self)
    self.client.get("/login")

  def test_policy_basic_import(self):
    filename = "ca_setup_for_deletion.csv"
    self.import_file(filename)

    filename = "ca_deletion.csv"
    response_data_dry = self.import_file(filename, dry_run=True)
    response_data = self.import_file(filename)
    self.assertEqual(response_data_dry, response_data)

    self.assertEqual(response_data[0]["deleted"], 2)
    self.assertEqual(response_data[0]["ignored"], 0)

## Instruction:
Optimize basic delete import tests
## Code After:

from integration.ggrc import TestCase


class TestBasicCsvImport(TestCase):

  def setUp(self):
    TestCase.setUp(self)
    self.client.get("/login")

  def test_policy_basic_import(self):
    filename = "ca_setup_for_deletion.csv"
    self.import_file(filename)

    filename = "ca_deletion.csv"
    response_data = self.import_file(filename)

    self.assertEqual(response_data[0]["deleted"], 2)
    self.assertEqual(response_data[0]["ignored"], 0)
