Exemplo n.º 1
0
 def test_process_file_with_one_row(self):
     the_file = os.path.abspath(__file__)
     with mock.patch('ncsales.cli.get_data') as mock_get_data:
         mock_get_data.return_value = [['1', 'web', '34.33']]
         self.assertEqual(
             [(1, 'bronze', 0)], list(cli.process_file(the_file))
         )
Exemplo n.º 2
0
 def test_process_file(self):
     the_file = os.path.abspath(__file__)
     with mock.patch('ncsales.cli.get_data') as mock_get_data:
         mock_get_data.return_value = [['1', 'web', '34.33'],
                                       ['', 'webinar', '55.4'],
                                       ['3', 'webinar', '15.4'],
                                       ['2', 'webinar', '55.4']]
         self.assertEqual(
             [(1, 'bronze', 4),
              (2, 'platinum', 100),
              (3, 'bronze', 0)], list(cli.process_file(the_file))
         )
Exemplo n.º 3
0
    def test_integration(self):
        with tempfile.NamedTemporaryFile() as source:
            source.write(b'''\
1, web, 34.33
1, email, 3.4
1, social, 4
2, webinar, 55.4
2, social, 15
3, social, 25
3, email, 63
''')
            source.seek(0)
            self.assertEqual(
                [(1, 'bronze', 0), (2, 'platinum', 100), (3, 'platinum', 77)],
                list(cli.process_file(source.name))
            )