A New Start
Since last Tuesday, I have started working at a new company: Tradir. Tradir is the company responsible for tradir.io, which is a collaboration web app for international trade. Leaving behind the previous project (brought to you by Hodosoft) was no easy process but the challenges at Tradir are much more burdensome. First of all, the codebase flaunts all sorts of advanced features of Python and Django. It’s been a week and I still have no idea how I am going to catch up with this. I need to create some sort of roadmap for just the onboarding process.
So far, I have crafted some unit tests. They take about 1 percent of the whole list of the Tradir application. Gotta start somewhere.
import pytest
import json
from django.urls import reverse
from django.contrib.auth.models import User
from django.test import Client
from mixer.backend.django import mixer
from user.models import SocialLoginPlatform
from contacts.models import Country
pytestmark = pytest.mark.django_db
client = Client()
@pytest.fixture()
def user():
user = mixer.blend(User, first_name="Nick", username="nickanism")
return user
@pytest.fixture()
def social_platform():
SocialLoginPlatform.objects.create(name="none")
social_platform = mixer.blend(SocialLoginPlatform, name="google")
return social_platform
@pytest.fixture()
def country():
country = mixer.blend(Country, name="South Korea", code="KR")
return country
@pytest.mark.django_db
def test_user_profile_check(user, social_platform, country):
assert user.first_name == "Nick"
assert social_platform.name == "google"
assert country.name == "South Korea"
assert user.profile != None
@pytest.mark.django_db
def test_user_creation_country_list(client, country):
url = reverse('country-list')
response = client.get(url)
assert response.status_code == 200
assert json.loads(response.content)['country_list'][0]['name'] == country.name