示例#1
0
class TestArgsParsing(UnitTestCase):
    def setUp(self):
        super(TestArgsParsing, self).setUp()
        self.command = Command()

    def test_return_empty_dict_on_empty_input(self):
        self.assert_equals({}, get_fields_to_extract([]))

    def test_fails_on_invalid_model(self):
        self.assert_equals(None, get_fields_to_extract(['not_a.model:field']))

    def test_fails_on_non_existent_field(self):
        self.assert_equals(
            None,
            get_fields_to_extract(['contenttypes.contenttype:not_a_field']))

    def test_fails_without_colon(self):
        self.assert_equals(None, get_fields_to_extract(['aljshfdlsah']))

    def test_fails_without_dot(self):
        self.assert_equals(None, get_fields_to_extract(['aljshfdlsah:field']))

    def test_works_for_single_input(self):
        self.assert_equals({'contenttypes.contenttype': ['name']},
                           get_fields_to_extract(
                               ['contenttypes.contenttype:name']))

    def test_groups_results_by_model(self):
        self.assert_equals({'contenttypes.contenttype': ['name', 'app_label']},
                           get_fields_to_extract([
                               'contenttypes.contenttype:name',
                               'contenttypes.contenttype:app_label'
                           ]))

    def test_fails_for_no_input(self):
        self.assert_equals(None, self.command.handle())

    def test_fails_for_incorrect_processor(self):
        self.assert_equals(None, self.command.handle('not-a-processor'))

    def test_fails_for_incorrect_fields(self):
        self.assert_equals(
            None, self.command.handle('markdown', 'not_a.model:field'))

    def test_works_for_no_fields(self):
        self.assert_equals(0, self.command.handle('markdown'))
class TestArgsParsing(UnitTestCase):
    def setUp(self):
        super(TestArgsParsing, self).setUp()
        self.command = Command()

    def test_return_empty_dict_on_empty_input(self):
        self.assert_equals({}, get_fields_to_extract([]))

    def test_fails_on_invalid_model(self):
        self.assert_equals(None, get_fields_to_extract(['not_a.model:field']))

    def test_fails_on_non_existent_field(self):
        self.assert_equals(None, get_fields_to_extract(['contenttypes.contenttype:not_a_field']))

    def test_fails_without_colon(self):
        self.assert_equals(None, get_fields_to_extract(['aljshfdlsah']))

    def test_fails_without_dot(self):
        self.assert_equals(None, get_fields_to_extract(['aljshfdlsah:field']))

    def test_works_for_single_input(self):
        self.assert_equals(
                {'contenttypes.contenttype': ['name']},
                get_fields_to_extract(['contenttypes.contenttype:name'])
            )

    def test_groups_results_by_model(self):
        self.assert_equals(
                {'contenttypes.contenttype': ['name', 'app_label']},
                get_fields_to_extract(['contenttypes.contenttype:name', 'contenttypes.contenttype:app_label'])
            )

    def test_fails_for_no_input(self):
        self.assert_equals(None, self.command.handle())

    def test_fails_for_incorrect_processor(self):
        self.assert_equals(None, self.command.handle('not-a-processor'))

    def test_fails_for_incorrect_fields(self):
        self.assert_equals(None, self.command.handle('markdown', 'not_a.model:field'))

    def test_works_for_no_fields(self):
        self.assert_equals(0, self.command.handle('markdown'))
示例#3
0
 def test_command_works_with_correct_params(self):
     command = Command()
     self.assert_equals(
         0, command.handle('markdown',
                           'contenttypes.contenttype:app_label'))
示例#4
0
 def setUp(self):
     super(TestArgsParsing, self).setUp()
     self.command = Command()
 def test_command_works_with_correct_params(self):
     command = Command()
     self.assert_equals(0, command.handle('markdown', 'contenttypes.contenttype:app_label'))
 def setUp(self):
     super(TestArgsParsing, self).setUp()
     self.command = Command()