def test_import_remove_add_dependant_service(self):
        # This test does: export all state, remove a dep from s1, import,
        # ensure the remove worked, add a dep to s1, import, make sure the
        # add worked

        # get an export so we can play with it
        sblob = self.get_service(self.s1.iql_stmt())

        # remember how many deps we started with
        old_dep_count = Dependency.objects.count()

        self.assertEqual(
            2, len(sblob['services'][0]['depends_on'])
        )
        # remove a dep
        sblob['services'][0]['depends_on'].remove(self.s2.iql_stmt())
        # Make sure the s3 service is still there
        self.assertTrue(
            self.s3.iql_stmt() in sblob['services'][0]['depends_on']
        )

        # import the new state
        _, resp = self.import_services(sblob)
        self.assertEqual(resp.status_code, 200, resp.content)

        # refresh state
        sblob = self.get_service(self.s1.iql_stmt())

        # we should only see one dep now
        self.assertEqual(
            1, len(sblob['services'][0]['depends_on'])
        )

        # make sure we deleted the right one. the old dep should still be there
        self.assertTrue(
            self.s3.iql_stmt() in sblob['services'][0]['depends_on']
        )

        # Make sure we only deleted one dep
        new_dep_count = Dependency.objects.count()
        self.assertEqual(
            old_dep_count - 1, new_dep_count,
            "It doesn't look like a dependency was deleted"
        )

        # add back the dep
        sblob['services'][0]['depends_on'].append(self.s2.iql_stmt())

        # import the new state
        _, resp = self.import_services(sblob)
        self.assertEqual(resp.status_code, 200, resp.content)

        # refresh state
        sblob = self.get_service(self.s1.iql_stmt())

        # ensure the new dep is there
        self.assertTrue(
            self.s2.iql_stmt() in sblob['services'][0]['depends_on']
        )
dataset/ETHPy150Open mozilla/inventory/core/service/tests/test_api.py/ServiceAPITests.test_import_remove_add_dependant_service/original