Example #1
0
class TestStaticMethods(TestCase):
    def setUp(self):
        self.cmd = LoadCommand()

    def test_get_file_name(self):
        expected = '1970-01-01-ahoy.xz'
        with self.settings(AMAZON_S3_DATASET_DATE='1970-01-01'):
            self.assertEqual(expected, self.cmd.get_file_name('ahoy'))

    def test_get_model_name(self):
        self.assertEqual('Activity', self.cmd.get_model_name(Activity))
Example #2
0
class TestStaticMethods(TestCase):
    def setUp(self):
        self.cmd = LoadCommand()

    def test_get_model_name(self):
        self.assertEqual('Activity', self.cmd.get_model_name(Activity))

    def test_to_date(self):
        expected = date(1991, 7, 22)
        self.assertEqual(self.cmd.to_date('22/7/91'), expected)
        self.assertEqual(self.cmd.to_date('1991-07-22 03:15:00+0300'),
                         expected)
        self.assertEqual(self.cmd.to_date('22/13/91'), None)
        self.assertEqual(self.cmd.to_date('aa/7/91'), None)
        self.assertEqual(self.cmd.to_date('22/07/16'), date(2016, 7, 22))

    def test_to_number(self):
        self.assertIsNone(self.cmd.to_number(''))
        self.assertIsNone(self.cmd.to_number('NaN'))
        self.assertIsNone(self.cmd.to_number('nan'))
        self.assertEqual(1.0, self.cmd.to_number('1'))
        self.assertEqual(1.2, self.cmd.to_number('1.2'))
        self.assertEqual(1, self.cmd.to_number('1', int))
        self.assertEqual(1, self.cmd.to_number('1.0', int))
class TestStaticMethods(TestCase):

    def setUp(self):
        self.cmd = LoadCommand()

    def test_get_model_name(self):
        self.assertEqual('Activity', self.cmd.get_model_name(Activity))

    def test_to_date(self):
        expected = date(1991, 7, 22)
        self.assertEqual(self.cmd.to_date('22/7/91'), expected)
        self.assertEqual(self.cmd.to_date('1991-07-22 03:15:00+0300'), expected)
        self.assertEqual(self.cmd.to_date('22/13/91'), None)
        self.assertEqual(self.cmd.to_date('aa/7/91'), None)
        self.assertEqual(self.cmd.to_date('22/07/16'), date(2016, 7, 22))

    def test_to_number(self):
        self.assertIsNone(self.cmd.to_number(''))
        self.assertIsNone(self.cmd.to_number('NaN'))
        self.assertIsNone(self.cmd.to_number('nan'))
        self.assertEqual(1.0, self.cmd.to_number('1'))
        self.assertEqual(1.2, self.cmd.to_number('1.2'))
        self.assertEqual(1, self.cmd.to_number('1', int))
        self.assertEqual(1, self.cmd.to_number('1.0', int))