added basic tests for StatsLogs
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from factory import SubFactory
|
from factory import SubFactory
|
||||||
from factory.fuzzy import FuzzyText, FuzzyInteger, FuzzyDateTime, FuzzyDate, FuzzyDecimal, FuzzyChoice, FuzzyDateTime
|
from factory.fuzzy import FuzzyText, FuzzyInteger, FuzzyDateTime, FuzzyDate, FuzzyDecimal, FuzzyChoice
|
||||||
from factory.django import DjangoModelFactory
|
from factory.django import DjangoModelFactory
|
||||||
|
|
||||||
from companies.factories import CompanyFactory
|
from companies.factories import CompanyFactory
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
import json
|
import json
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from rest_framework.test import APITestCase
|
from rest_framework.test import APITestCase
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
@@ -99,26 +102,24 @@ class ProductViewSetTest(APITestCase):
|
|||||||
"""
|
"""
|
||||||
# Define request data
|
# Define request data
|
||||||
data = {
|
data = {
|
||||||
'cif': 'qwerewq',
|
'company': None,
|
||||||
'company_name': 'qwerewq',
|
'sku': 'qwerewq',
|
||||||
'short_name': 'qwerewq',
|
'name': 'qwerewq',
|
||||||
'web_link': 'http://qwerewq.com',
|
'description': 'qwerewq',
|
||||||
'shop': True,
|
'image': None,
|
||||||
'shop_link': 'http://qwerewq.com',
|
'url': 'http://qwerewq.com',
|
||||||
'platform': 'PRESTASHOP',
|
'price': '12.21',
|
||||||
'email': 'test@email.com',
|
'shipping_cost': '21.12',
|
||||||
'logo': None,
|
'shipping_terms': 'qwerewq',
|
||||||
'city': None,
|
'source': 'SYNCHRONIZED',
|
||||||
'address': 'qwer qewr 5',
|
'sourcing_date': datetime.datetime.now().isoformat()+'Z',
|
||||||
'geo': None,
|
'update_date': datetime.datetime.now().isoformat()+'Z',
|
||||||
'phone': '1234',
|
'discount': '0.05',
|
||||||
'mobile': '4321',
|
'stock': 22,
|
||||||
'other_phone': '41423',
|
# tags = models.ManyToMany(Tag, null=True, blank=True )
|
||||||
'description': 'dfgfdgdfg',
|
# category = models.ForeignKey(Tag, null=true) # main tag category
|
||||||
'shop_rss_feed': 'http://qwerewq.com',
|
# attributes = models.ManyToMany(Tag, null=True, blank=True )
|
||||||
'sale_terms': 'tewrnmfew f ewfrfew ewewew f',
|
'identifiers': '34rf34f43c43',
|
||||||
'shipping_cost': '12.25',
|
|
||||||
'sync': False
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Authenticate user
|
# Authenticate user
|
||||||
@@ -145,26 +146,24 @@ class ProductViewSetTest(APITestCase):
|
|||||||
|
|
||||||
# Define request data
|
# Define request data
|
||||||
data = {
|
data = {
|
||||||
'cif': 'qwerewq',
|
'company': None,
|
||||||
'company_name': 'qwerewq',
|
'sku': 'qwerewq',
|
||||||
'short_name': 'qwerewq',
|
'name': 'qwerewq',
|
||||||
'web_link': 'http://qwerewq.com',
|
'description': 'qwerewq',
|
||||||
'shop': True,
|
'image': None,
|
||||||
'shop_link': 'http://qwerewq.com',
|
'url': 'http://qwerewq.com',
|
||||||
'platform': 'PRESTASHOP',
|
'price': '12.21',
|
||||||
'email': 'test@email.com',
|
'shipping_cost': '21.12',
|
||||||
'logo': None,
|
'shipping_terms': 'qwerewq',
|
||||||
'city': None,
|
'source': 'SYNCHRONIZED',
|
||||||
'address': 'qwer qewr 5',
|
'sourcing_date': datetime.datetime.now().isoformat()+'Z',
|
||||||
'geo': None,
|
'update_date': datetime.datetime.now().isoformat()+'Z',
|
||||||
'phone': '1234',
|
'discount': '0.05',
|
||||||
'mobile': '4321',
|
'stock': 22,
|
||||||
'other_phone': '41423',
|
# tags = models.ManyToMany(Tag, null=True, blank=True )
|
||||||
'description': 'dfgfdgdfg',
|
# category = models.ForeignKey(Tag, null=true) # main tag category
|
||||||
'shop_rss_feed': 'http://qwerewq.com',
|
# attributes = models.ManyToMany(Tag, null=True, blank=True )
|
||||||
'sale_terms': 'tewrnmfew f ewfrfew ewewew f',
|
'identifiers': '34rf34f43c43',
|
||||||
'shipping_cost': '12.25',
|
|
||||||
'sync': False
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Authenticate user
|
# Authenticate user
|
||||||
|
|||||||
20
stats/factories.py
Normal file
20
stats/factories.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import datetime
|
||||||
|
from django.utils import timezone
|
||||||
|
from factory import SubFactory
|
||||||
|
from factory.fuzzy import FuzzyText, FuzzyInteger, FuzzyDateTime, FuzzyDate, FuzzyDecimal, FuzzyChoice
|
||||||
|
from factory.django import DjangoModelFactory
|
||||||
|
|
||||||
|
|
||||||
|
class StatsLogFactory(DjangoModelFactory):
|
||||||
|
|
||||||
|
model = None
|
||||||
|
user = SubFactory('core.factories.CustomUserFactory')
|
||||||
|
anonymous = FuzzyChoice(choices=(True, False))
|
||||||
|
ip_address = '127.0.0.1'
|
||||||
|
geo = None
|
||||||
|
contact = FuzzyChoice(choices=(True, False))
|
||||||
|
shop = FuzzyChoice(choices=(True, False))
|
||||||
|
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = 'stats.StatsLog'
|
||||||
Reference in New Issue
Block a user