Codeception - different path to test folder - unit-testing

Is there any way to tell the codeception config files I have stored my tests in different folder than default. As default, tests are stored in vendor/codeception/codeception/tests folder, I want to have my tests outside vendor folder. just in /tests folder. Something like ../tests doesn't work in *.yml file.

Related

Azure web app intermittently copying code from tmp to home

I am deploying a Django appication to a Azure Web App via Github Actions. The code is consistently deployed to the tmp folder but is not always copied to wwwroot, even though Oryx deployment logs state that the contents are copied. What causes this intermittent behaviour?
Detecting platforms...
Detected following platforms:
python: 3.8.12
Using intermediate directory '/tmp/8da59cae1f18fde'.
Copying files to the intermediate directory...
Done in 0 sec(s).
Source directory : /tmp/8da59cae1f18fde
Destination directory: /home/site/wwwroot
Python Version: /opt/python/3.8.12/bin/python3.8
Creating directory for command manifest file if it doesnot exist
Removing existing manifest file
Python Virtual Environment: antenv
Creating virtual environment...
Activating virtual environment...
Running pip install...
Content in source directory is a Django app
Running collectstatic...
Done in 18 sec(s).
Not a vso image, so not writing build commands
Preparing output...
Copying files to destination directory '/tmp/_preCompressedDestinationDir'...
Done in 31 sec(s).
Compressing content of directory '/tmp/_preCompressedDestinationDir'...
Copied the compressed output to '/home/site/wwwroot'
Removing existing manifest file
Creating a manifest file...
Manifest file created.
Done in 244 sec(s).
For others that may be struggling with this same issue, specifically with Django applications, I have landed on the following workaround:
After learning more about how Oryx build actually works, I now understand that the code IS copied to wwwroot - but as a tarball. The code is then extracted to tmp and executed in this folder. This causes a challenge running django migrations as the migration folder is not persistent at the location where the code is run from, i.e. you are not able to run migrations automatically from the tmp folder (because, assuming you are not putting your migrations in source control, there is no migration history here.) and you are not able to run migrations from wwwroot (because the new code only exists in the tarball). So, in order to persist migration history you will need to:
Extract output.tar.gz in its entirety to wwwroot and overwrite existing files.
OR
Do 1. ONCE in order to get your project structure ready to perform migrations in wwwroot, and after this copy only the files needed to detect database changes (in my case settings.py, forms.py, models.py and admin.py) from tmp to wwwroot. This can be done automatically by editing the startup command.

Using Snowpack to transpile Web Components and package dependencies

I am using Django to build a SSR website and using Django to serve static files. I also built some Web Components using lit-element and Typescript. I would like to avoid the complexity of Webpack and use Snowpack instead. Components are stored at /static/js/components.
To use the components, I need to (1) transpile them to Javascript, (2) make available their dependencies (e.g. lit-element) and (3) move the transpired files as well as the _snowpack folder to Django's /static/ folder.
Using just snowpack build does both but creates a build folder with a complete copy of the application. It is my understanding that buildOptions.out only moves the output folder (thereby overwriting static/ altogether if buildOptions.clean===true). I guess it would be possible to script the copying of the necessary files and delete the rest of the build folder immediately, but that strikes me as quite inelegant.
Is there a configuration to only create _snowpack and the transpiled files to a specific directory?
The Django staticfiles module supports having multiple directories for static files, and making them all available under the same /static/ URL.
That way, you won't have to copy those different type of assets into the same folder before being able to serve them with Django.

How can I change the name(s) of folders in my Django project without destroying its ability to find its own parts?

I'm reading through Two Scoops of Django and the authors note that best practices involve having a config folder and an apps folder. I've been building a Django project for the last few months here & there and want to get in the habit of complying with these practices, but when I change the name of my <project_name> folder (with the wsgi, settings, etc.), Django can't seem to find the contents of the folder anymore.
How do I change this folder name and put the project apps into an app folder without breaking the connections they have?
Restoring connection can be a painful process and even if you restore the connections, there is no guarantee it will always work (eg, some 3rd party app may fail because of dependency issues which you forgot to change).
I do like to separate my created apps and project folder to be visibly different too. For this, I create parent folder which would be my entire django installation and then inside the created folder I create the project while telling that this is the directory I'd like to use. Lets say I want to create blog project:
$ mkdir blog
$ cd blog
$ django-admin startproject blog_project .
This will give you a blog folder and inside it you will get blog_project folder and beloved manage.py.

How can I store my static files to some other github repo?

I am doing a Django Project and I want to store some files (which should be accessible from the project w,r) to some github project as I don't want to store the files and the projects in the same repo.
Any suggestion of doing that?
Let's say, for example, that you want to upload all files with a .css extension to a separate project.
You need to create two files in the root folder of each project. and call them .gitignore
(Don't forget the point at first)
In the repository where you want all files except css files, write in the .gitignore file:
*.css
In the repository where you only want the css files, write in the .gitignore file:
*
!*.css
You will now push the .gitignore files, respectively, to each of the projects you created.

Appropriate placement for my testcases belonging to a non-app in Django

I have built my website in Django. And like any other django project I have got apps inside the project root directory and some special folders like(extensions a.k.a custom django command extensions). With an app, we dont have any problem with having testcases. "tests.py" inside the app directory will be the solution. But for a special folder(which is not an app or which doesn't have a models.py) where do I place the testcases. I tried placing the tests.py inside the extensions directory and it said the directory is not a model and unable to run the tests. HOw do I solve this? How can I have a proper placement of testcases related to non-apps?
I think it will work to put them in a tests/ directory at the project level.
If, for some reason, it doesn't then try creating an empty models.py in your extensions directory.