示例#1
0
    def test_get_channels_categories_is_up(self, client, initial_data):
        channel = initial_data['channel']
        categories = ['Books', 'National Literature', 'Science Fiction']
        Category.create_channel_categories(channel=channel,
                                           categories=categories)

        url = reverse('core:category_list',
                      kwargs={'channel': initial_data['channel'].pk})

        response = client.get(url)
        assert response.status_code == 200
    def handle(self, *args, **options):
        channel, _ = Channel.objects.get_or_create(name=options['channel'])
        Category.objects.filter(channel=channel).delete()
        with open(options['file']) as categories_file:
            categories_reader = csv.reader(categories_file)
            next(categories_reader)
            for row in categories_reader:
                count = Category.create_channel_categories(channel, row[0].split(' / '))
                self.stdout.write('Processed {} Categories'.format(count))

        self.stdout.write(self.style.SUCCESS('Categories imported!'))
示例#3
0
 def test_create_categories_from_list(self, initial_data):
     channel = initial_data['channel']
     categories = ['Books', 'National Literature', 'Science Fiction']
     created = Category.create_channel_categories(channel=channel,
                                                  categories=categories)
     assert created == len(categories)